package org.sy.lab.多线程基础._3_同步辅助类._5_Exchanger交换者;

import java.util.concurrent.Exchanger;

//Exchanger用于两个线程在到达同步点时交换数据
//可以用于遗传算法和校对工作
//例子中对产生后的2个银行流水进行比较
public class Main {
	
	public static void main(String[] args) {
		
		Exchanger<Integer> exchanger = new Exchanger<Integer>();
		
		Account1 account1 = new Account1(exchanger);
		Account2 account2 = new Account2(exchanger);
		
		Thread thread1 = new Thread(account1, "银行账单1");
		Thread thread2 = new Thread(account2, "银行账单2");
		
		thread1.start();
		thread2.start();
	}
}
